mydns安装配置

        远程下载

        rpm包下载

1.因为mydns依赖mysql,所以需要先安装mysql。

1
yum install -y mysql-server

2 安装mydns

1
2
wget http://www.lishiming.net/data//a ... ql-1.1.0-1.i386.rpm
rpm -ivh mydns-mysql-1.1.0-1.i386.rpm

3.创建库和表

1
2
3
4
5
mysql -uroot -e "create database mydns"
mysql -uroot mydns
mysql> CREATE TABLE `soa` ( `id` int(10) unsigned NOT NULL auto_increment, `origin` char(255) default NULL, `ns` char(255) default NULL, `mbox` char(255) default NULL, `serial` int(10) unsigned default '1', `refresh` int(10) unsigned default '28800', `retry` int(10) unsigned default '7200', `expire` int(10) unsigned default '604800', `minimum` int(10) unsigned default '86400', `ttl` int(10) unsigned default '86400', `xfer` char(255) default NULL, PRIMARY KEY (`id`), UNIQUE KEY `origin` (`origin`) ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=gbk;
mysql> CREATE TABLE `rr` ( `id` int(10) unsigned NOT NULL auto_increment, `zone` int(10) unsigned NOT NULL, `name` char(64) default NULL, `type` enum('A','AAAA','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT') default NULL, `data` char(128) default NULL, `aux` int(10) unsigned NOT NULL, `ttl` int(10) unsigned NOT NULL default '600', `inter` tinyint(3) unsigned NOT NULL default '1', `intra` tinyint(3) unsigned NOT NULL default '1', PRIMARY KEY (`id`), KEY `name` (`name`), KEY `rr` (`zone`,`name`,`type`,`data`) ) ENGINE=MyISAM AUTO_INCREMENT=1437896 DEFAULT CHARSET=gbk;

4.创建第一个zone

1
2
3
mysql> use mydns
mysql> insert into soa (id, origin,ns,mbox,serial,refresh,retry,expire,minimum,ttl) values(1,'abc.com.', 'ns.abc.com.', 'root.aminglinux.com', 1, 28800, 7200, 604800, 86400, 86400);
mysql> insert into rr values(1, 1, 'www', 'A', '1.1.1.1', 0, 1, 1, 1, 1);

5.配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
mysql> show create table soa\G;
CREATE TABLE `soa` ( `id` int(10) unsigned NOT NULL auto_increment, `origin` char(255) default NULL, `ns` char(255) default NULL, `mbox` char(255) default NULL, `serial` int(10) unsigned default '1', `refresh` int(10) unsigned default '28800', `retry` int(10) unsigned default '7200', `expire` int(10) unsigned default '604800', `minimum` int(10) unsigned default '86400', `ttl` int(10) unsigned default '86400', `xfer` char(255) default NULL, PRIMARY KEY (`id`), UNIQUE KEY `origin` (`origin`) ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=gbk;
mysql> show create table rr\G;
*************************** 1. row ***************************
Table: rr
CREATE TABLE `rr` ( `id` int(10) unsigned NOT NULL auto_increment, `zone` int(10) unsigned NOT NULL, `name` char(64) default NULL, `type` enum('A','AAAA','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT') default NULL, `data` char(128) default NULL, `aux` int(10) unsigned NOT NULL, `ttl` int(10) unsigned NOT NULL default '600', `inter` tinyint(3) unsigned NOT NULL default '1', `intra` tinyint(3) unsigned NOT NULL default '1', PRIMARY KEY (`id`), KEY `name` (`name`), KEY `rr` (`zone`,`name`,`type`,`data`) ) ENGINE=MyISAM AUTO_INCREMENT=1437896 DEFAULT CHARSET=gbk;
mysql> select * from soa where id=3;
+----+--------------+--------------+---------------------+--------+---------+-------+--------+---------+-------+------+
| id | origin | ns | mbox | serial | refresh | retry | expire | minimum | ttl | xfer |
+----+--------------+--------------+---------------------+--------+---------+-------+--------+---------+-------+------+
| 3 | example.com. | ns.example.com. | julyclyde.gmail.com | 1 | 28800 | 7200 | 604800 | 86400 | 86400 | NULL |
mysql> select * from rr where id=1;
+----+------+------+------+----------------+-----+-----+-------+-------+
| id | zone | name | type | data | aux | ttl | inter | intra |
+----+------+------+------+----------------+-----+-----+-------+-------+
| 1 | 1 | www | A | 1.1.1.1 | 0 | 1 | 1 | 1 |
cat /etc/mydns.conf
##
## /etc/mydns.conf
## Wed Nov 19 10:04:14 2008
## For more information, see mydns.conf(5).
##
# DATABASE INFORMATION
db-host = localhost # SQL server hostname
db-user = yourdbname # SQL server username
db-password = yourpassword # SQL server password
database = dns # MyDNS database name
# GENERAL OPTIONS
user = nobody # Run with the permissions of this user
group = nobody # Run with the permissions of this group
listen = * # Listen on these addresses ('*' for all)
no-listen = # Do not listen on these addresses
# CACHE OPTIONS
zone-cache-size = 1024 # Maximum number of elements stored in the zone cache
zone-cache-expire = 60 # Number of seconds after which cached zones expires
reply-cache-size = 1024 # Maximum number of elements stored in the reply cache
reply-cache-expire = 30 # Number of seconds after which cached replies expire
# ESOTERICA
log = /var/log/mydns.log # Facility to use for program output (LOG_*/stdout/stderr)
pidfile = /var/run/mydns.pid # Path to PID file
timeout = 120 # Number of seconds after which queries time out
multicpu = 4 # Number of CPUs installed on your system - (deprecated)
servers = 2 # Number of servers to run
recursive = 8.8.8.8 # Location of recursive resolver
recursive-timeout = # Number of seconds before first retry
recursive-retries = # Number of retries before abandoning recursion
recursive-algorithm = # Recursion retry algorithm one of: linear, exponential, progressive
allow-axfr = no # Should AXFR be enabled?
allow-tcp = no # Should TCP be enabled?
allow-update = no # Should DNS UPDATE be enabled?
ignore-minimum = no # Ignore minimum TTL for zone?
soa-table = soa # Name of table containing SOA records
rr-table = rr # Name of table containing RR data
use-soa-active = no # Use the soa active attribute if provided
use-rr-active = no # Use the rr active attribute if provided
notify-enabled = no # Enable notify from updates
notify-source = 0.0.0.0 # Source address for ipv4 notify messages
notify-source6 = 0.0.0.0 # Source address for ipv6 notify messages
notify-timeout = 60 # Number of seconds before first retry
notify-retries = 5 # Number of retries before abandoning notify
notify-algorithm = linear # Notify retry algorithm one of: linear, exponential, progressive
ixfr-enabled = no # Enable IXFR functionality
ixfr-gc-enabled = no # Enable IXFR GC functionality
ixfr-gc-interval = 86400 # How often to run GC for IXFR
ixfr-gc-delay = 600 # Delay until first IXFR GC runs
extended-data-support = no # Support extended data fields for large TXT records
dbengine = MyISAM # Support different database engines
wildcard-recursion = 0 # Wildcard ancestor search levels
soa-where = # Extra WHERE clause for SOA queries
rr-where = inter=1 # Extra WHERE clause for RR queries

6.启动

1
/etc/init.d/mydns start